﻿<Page x:Class="SellAvi.Views.PageAdditionals"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
      xmlns:command="http://www.galasoft.ch/mvvmlight"
      mc:Ignorable="d"
      Title="Дополнительные характеристики товара">
    <!--DataContext="{Binding EditProduct, Source={StaticResource Locator}}"-->
    <Grid Margin="4">
        <Grid.Resources>
            <Style TargetType="{x:Type Label}">
                <Setter Property="Padding" Value="0,0,0,0" />
            </Style>
            <Style TargetType="{x:Type TextBox}">
                <Setter Property="Margin" Value="0,1,0,1" />
                <Setter Property="Padding" Value="0,0,0,0" />
            </Style>
            <Style TargetType="{x:Type ComboBox}">
                <Setter Property="Margin" Value="0,1,0,1" />
                <Setter Property="Padding" Value="4,0,4,0" />
            </Style>
            <Style TargetType="ListBox">
                <!-- Rest of the style -->
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22" MinHeight="90"/>
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22" />
            <RowDefinition Height="22"  />
            <RowDefinition Height="22" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!--<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding CurrentAvitoProduct.AvitoUser.CompanyManager}" IsEnabled="False"></TextBox>-->

        <Label Grid.Row="0" Grid.Column="0" Content="Исходный Url"></Label>
        <DockPanel Grid.Row="0" Grid.Column="1">
            <Button  DockPanel.Dock="Right" Command="{Binding NavigateToCommand}" CommandParameter="{Binding CurrentAvitoProduct.ParsedFromUrl}" Height="20" Width="20">
                <Image Source="/SellAvi;component/Resources/arrow3_e.png"></Image>
            </Button>
            <TextBox  Text="{Binding CurrentAvitoProduct.ParsedFromUrl}" IsEnabled="False"></TextBox>
        </DockPanel>


        <Label Grid.Row="1" Grid.Column="0" Content="Url публикации"></Label>
        <DockPanel Grid.Row="1" Grid.Column="1" >
            <Button  DockPanel.Dock="Right" Command="{Binding NavigateToCommand}" CommandParameter="{Binding CurrentAvitoProduct.PostedOnUrl}" Height="20" Width="20">
                <Image Source="/SellAvi;component/Resources/arrow3_e.png"></Image>
            </Button>
            <TextBox  Text="{Binding CurrentAvitoProduct.PostedOnUrl}" IsEnabled="False"></TextBox>
        </DockPanel>


        <Label Grid.Row="2" Grid.Column="0" Content="Город владельца"></Label>
        <ComboBox  Grid.Row="2" Grid.Column="1" ItemsSource="{Binding ServiceProxy.GetRegions}" DisplayMemberPath="RegionName" SelectedValue="{Binding CurrentAvitoProduct.TRegion_Id}" SelectedValuePath="Id" IsReadOnly="True"></ComboBox>

        <Label Grid.Row="3" Grid.Column="0" Content="Телефон владельца"></Label>
        <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding CurrentAvitoProduct.ParsedPhone}" IsEnabled="False"></TextBox>


        <StackPanel Grid.Row="4" Grid.Column="0">
            <DockPanel>
                <Button  DockPanel.Dock ="Left" Background="WhiteSmoke" Command="{Binding AddLinkPhotoCommand}" Height="20" Width="20">
                    <Image Source="/SellAvi;component/Resources/html.png" Stretch="UniformToFill"></Image>
                </Button>
                <Button  Background="WhiteSmoke" Command="{Binding AddProductPhotoCommand}" Height="20">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <Image Source="/SellAvi;component/Resources/open.png" Stretch="UniformToFill"></Image>
                        <Label Padding="5,0,0,0" Content="Добавить фотографию" FontSize="10"></Label>
                    </StackPanel>
                </Button>
            </DockPanel>
            <Button  DockPanel.Dock ="Left" Background="WhiteSmoke" Command="{Binding StarSelectedPhotoCommand}" Height="20" Width="20" HorizontalAlignment="Left" ToolTip="Сделать изображение главным">
                <Image Source="/SellAvi;component/Resources/star.png" Stretch="UniformToFill"></Image>
            </Button>
            <Button  DockPanel.Dock ="Left" Background="WhiteSmoke" Command="{Binding DeleteSelectedPhotoCommand}" Height="20" Width="20" HorizontalAlignment="Left" ToolTip="Удалить изображение">
                <Image Source="/SellAvi;component/Resources/trash.png" Stretch="UniformToFill"></Image>
            </Button>


        </StackPanel>
        <ListBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding CurrentAvitoImages}" BorderThickness="0">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <command:EventToCommand
                Command="{Binding PhotoSelectionChangedCommand}"
                CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <!--ListView-->
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding LocalImageFile}" Stretch="UniformToFill" Width="70" Height="70" Margin="0,0,2,0"></Image>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


        <Label Grid.Row="5" Grid.Column="0" Content="Ссылка на YouTube"></Label>
        <TextBox Grid.Row="5" Grid.Column="1" Text="{Binding CurrentAvitoProduct.YouTubeUrl}"></TextBox>

    </Grid>
</Page>
